<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title id="title">gorgeous-doc</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css"
          th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/layui/nprogress/nprogress.css}">
    <div th:include="common/common.html"></div>
    <style type="text/css">
        #steps {
            width: 95%;
            margin: 10px auto;
        }

        .steps-plant, .steps-plant-btn {
            width: 55%;
            padding: 10px;
            margin: 10px auto;
        }
    </style>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header header " id="header">

        <div class="layui-logo">
            <span style="font-size: 22px;color: #fff">gorgeous-doc</span>
        </div>
    </div>
    <div class="site-content" style="margin-top: 100px;">
        <div id="steps">
        </div>
        <div class="steps-plant steps-plant-0 git-plant">
            <div th:include="git/gitTemplate.html"></div>
        </div>
        <div class="steps-plant steps-plant-1 git-plant layui-hide">
            <div th:include="project/projectCloneTemplate.html"></div>
        </div>
        <div class="steps-plant steps-plant-2 git-plant layui-hide">
            <div th:include="env/envAddTemplate.html"></div>
        </div>
        <div class="steps-plant steps-plant-3 git-plant layui-hide">
            <div>完成</div>
        </div>
        <div class="steps-plant-btn">
            <button type="button" class="layui-btn " style="float: right" onclick="stepsFun.nextBtn()">下一步</button>
            <button type="button" class="layui-btn " style="float: right;margin-right: 10px" onclick="stepsFun.backBtn()">上一步</button>
        </div>
    </div>
</div>

<script type="text/javascript">
    layui.use(modes, function () {
        let load = function () {
            steps.render({
                ele: '#steps',
                data: [
                    {'title': "git配置", "desc": ""},
                    {'title': "创建一个项目", "desc": ""},
                    {'title': "配置环境", "desc": ""},
                    {'title': "完成", "desc": ""}
                ], //desc 不是必须
                //current: 2 //默认为第几步
            });
            stepsFun.steps = steps;
            //git
            stepsFun.getNext(0);
            saveProject(function () {
                stepsFun.getNext(0);
            });
            saveEnv(function () {
                stepsFun.getNext(0);
            })

        }
        loadScript(['js/config','js/git/git', 'js/env/env', 'js/project/project'], load);

    });

    let stepsFun = {
        steps: null,
        getNext: function (i) {
            if (i === 0) {
                getGitInfo(stepsFun.git);
            } else if (i === 1) {
                stepsFun.git(true);
            } else if (i === 2) {
                stepsFun.project([true]);
            }
        }
        , project: function (data) {
            if (data && data.length > 0) {
                stepsFun.steps.show(2);
                //环境
                getEnvAll(function (data) {
                    if (data && data.length > 0) {
                        stepsFun.steps.show(3);
                        window.location.href = context + "docs";
                    }
                })
            }
        }
        , git: function (data) {
            if (data) {
                stepsFun.steps.show(1);
                //项目
                projectAll(stepsFun.project);
            }
        }
        , nextBtn: function (){
            stepsFun.steps.next(1);
        }
        , backBtn: function (){
            stepsFun.steps.next(-1);
        }
    }


</script>
</body>
</html>